package pl.edu.pw.MidEmu.Common.Models;

import java.io.File;
import java.io.Serializable;

import javax.swing.Icon;
import javax.swing.ImageIcon;

/**
 * Model class representing Midas virtual node 
 * Contains Midas virtual node settings
 * @author Mateusz Starodab
 *
 */
public class ComponentTypeModel implements Serializable
{
	/**
	 * Enumeration for device types
	 * @author mateusz
	 *
	 */
	public enum ComponentType
	{
		Desktop, Laptop, Mainframe, Mobile, Other, Palmtop, Sensor
	}

	private static final long serialVersionUID = 7655084294077990439L;

	private String componentDescription;

	private String componentName;

	private ComponentType componentType;

	private Icon icon = null;

	private String imagePath;

	/**
	 * Gets component description
	 * @return Component description
	 */
	public String getComponentDescription()
	{
		return componentDescription;
	}

	/**
	 * Gets component name
	 * @return Component name
	 */
	public String getComponentName()
	{
		return componentName;
	}

	/**
	 * Gets component type
	 * @return Component type
	 */
	public ComponentType getComponentType()
	{
		return componentType;
	}

	/**
	 * Gets device icon
	 * @return Device Icon
	 */
	public Icon getIcon()
	{
		if (icon == null)
			icon = new ImageIcon(getImagePath());
		return icon;
	}

	/**
	 * Gets Icon height
	 * @return Icon height
	 */
	public int getIconHeight()
	{
		return getIcon().getIconHeight();
	}

	/**
	 * Gets Icon width
	 * @return Icon width
	 */
	public int getIconWidth()
	{
		return getIcon().getIconWidth();
	}

	/**
	 * Gets Icon path
	 * @return Icon path
	 */
	public String getImagePath()
	{
		return imagePath.replace('\\', File.separatorChar);
	}

	/**
	 * Sets component description
	 * @param componentDescription Component description
	 */
	public void setComponentDescription(String componentDescription)
	{
		this.componentDescription = componentDescription;
	}

	/**
	 * Sets component name
	 * @param componentName Component name
	 */
	public void setComponentName(String componentName)
	{
		this.componentName = componentName;
	}

	/**
	 * Sets component type
	 * @param componentType Component type
	 */
	public void setComponentType(ComponentType componentType)
	{
		this.componentType = componentType;
	}

	/**
	 * Sets image path
	 * @param imagePath Image path
	 */
	public void setImagePath(String imagePath)
	{
		this.imagePath = imagePath.replace(File.separatorChar, '\\');
	}
}
